<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .asd{
            width: 88px;
            height: 88px;
            background: red;
            border-radius: 20px;
            border: 2px solid rgb(38, 11, 145);
            position: fixed;
        }
    </style>
</head>
<body>
    <div class="asd"></div>
</body>
</html>
<script>
    const asd = document.querySelector('.asd')
    let offserX = 0;
    let offserY = 0;
    function oft(e){
        const X = e.clientX - offserX
        const Y = e.clientY - offserY
        asd.style.top = Y + 'px'
        asd.style.left = X + 'px'
    }
    asd.addEventListener('mousedown', f => {
        offserX = f.offsetX
        offserY = f.offsetY
        document.addEventListener('mousemove',oft)
    })
    document.addEventListener('mouseup',f => {
        document.removeEventListener('mousemove',oft)
    })
</script>